import { Component, OnInit } from '@angular/core';

import { Router, ActivatedRoute, NavigationExtras, ParamMap } from '@angular/router';

@Component({
  selector: 'app-first',
  templateUrl: './first.component.html',
  styleUrls: ['./first.component.css']
})
export class FirstComponent implements OnInit {

  private  bookId;

  constructor(
    private route: ActivatedRoute, // 包含与当前组件相关的路由信息
    private router: Router  // 一个提供导航和操纵 URL 能力的 NgModule
  ) { }


  ngOnInit(): void {
    this.bookId = this.route.snapshot.params.id;
    console.log(this.bookId);
  }


  toSecondPage() {
   // this.router.navigate(['../second'], { relativeTo: this.route });
    this.router.navigate(['../second', {id: 20}]);
    console.log('to second page');
  }
}
